package com.gzz.demo.pattern.command;

import java.util.List;

/**
 * 调用器
 */
public class Invoker {
    private ICommand command;
    private List<ICommand> commands; //已经执行完毕的命令集合
    public Invoker(ICommand command){
        this.command = command;
    }
    public void action(){
        command.Execute();
    }

    public void actionAll(){
        commands.stream().forEach(cmd->{
            cmd.Execute();
        });
    }
    public void addCommand (ICommand command){
        //commands.add(i,command);
        commands.add(command);
    }
}
